	var indicator = null;
	function load_graph(form){
		var showImage = function(){
			if ($('graphContainer').getElement('img') && 
				$('graphContainer').getElement('img').complete) $('graphContainer').tween('opacity',1);	
			else showImage.delay(1000);
		}
		$('graphContainer').tween('opacity',0);	
		
		var anyChecked = false;
		$$("input[type=checkbox]").each(function(item){
			anyChecked |= item.checked;
		})
		if (!anyChecked) return;
		
		form.set('action',APP.base+'/getGraph').set('send',{
			onSuccess: function(res){
				if (res) {
//					alert(res);
					res = res.replace(/href/gi,'onclick');
					$('graphContainer').empty().set('html', res)
						.getElements('area').each(function(item){
							item.addEvent('click', function(e){ new Event(e).stop(); })
								.href="#";
						});
					$('graphContainer').getElement('img').addEvent('click',function(){
						document.location = APP.base + '/printable';
					})
				}
				showImage.delay(1000);
				FBModal_hide();
			}		 
		}).send();
	}
	
	function load_drillGraph(data){
		var target = data.type==1? 
				APP.base+"/getDrillAvgReward/"+data.deptID+"/"+data.startPeriode+"/"+data.endPeriode : 
				APP.base+"/getDrillAvgPunishment/"+data.deptID+"/"+data.startPeriode+"/"+data.endPeriode;
			
			FBModal_show2( target , 'post', "", true, true, null);	
	}
	
	window.addEvent('domready', function(){
		load_graph($$('form')[0]);
		APP.periode1 = dtpicker_attach0($('periode1'), {timePicker:false, inputOutputFormat:'Y-m-d', format: 'F-Y', 
			maxDate: { date: $('periode1').value, format: 'Y-m-d' },
			onClose: function(){ 
				APP.periode2.options.minDate = {date:APP.periode1.attachTo.value, format:'Y-m-d'};
				APP.periode2.formatMinMaxDates();
				load_graph($$('form')[0]);
			}
		});
		APP.periode2 = dtpicker_attach0($('periode2'), {maxDate:{ date: $('periode2').value, format: 'Y-m-d' }, 
			timePicker:false, inputOutputFormat:'Y-m-d', format: 'F-Y', onClose: function(){ load_graph($$('form')[0]);} 
		});
	});